How to merge multiple reports in single PDF file through VBA code


Here's given an article which will guide you to "How to merge multiple reports in single PDF using VBA" in MS Access.

While working with reports, user often needs to merge two or more reports in PDF format. For that we need to PDF software that will able to merge the PDF format files. In this article we use the PSM software object to merge reports.

This article explained through an example here:-

create form with one button. When the user click on this button then merge the two reports in single PDF and place in "C" drive. Fig: - 1.1 show the form.

How to register and add reference of DLL through VBA code Fig-1.1

Fig:-1.1

After click on button then appears a message box show the confermation of successfully perform operation. As shown in fig: - 1.2

How to register and add reference of DLL through VBA code Fig-1.2

Fig:-1.2

Here is the VBA Code provided for Merge multiple reports in one PDF file:-

Option Compare Database
Private Sub Command0_Click()
Dim PDF
Dim strPdfFile As String
DoCmd.OutputTo acOutputReport, "Report1", "PDF Format (*.PDF)", "c:\Report1.PDF", False
DoCmd.Close acReport, "Report1", acSaveNo
DoCmd.OutputTo acOutputReport, "Report2", "PDF Format (*.PDF)", "c:\Report2.PDF", False
DoCmd.Close acReport, "Report2", acSaveNo
strPdfFile = "c:\Report1.PDF|c:\Report2.PDF"
Set PDF = CreateObject ("PDFSplitMerge.PDFSplitMerge.1")
PDF.Merge strPdfFile, "c:\Report3.PDF"
MsgBox "Success", vbInformation
End Sub


DISCLAIMER

It is advised that the information provided in the article should not be used for any kind formal or production programming purposes as content of the article may not be complete or well tested. ERP Makers will not be responsible for any kind of damage (monetary, time, personal or any other type) which may take place because of the usage of the content in the article.


 

BUY SERVICES CONTACT